1. Technical Field of the Invention
This invention relates to computer applications. More particularly, it relates to a system and method for managing tasks in a queue of tasks scheduled for future execution.
2. Background Art
Computer applications often require the ability to schedule tasks for future execution. An example of such an application is the general timer support of the Hardware Management Console (HMC).
Referring to FIG. 1, typically tasks 122, 124, and 126 are queued and watched over, as is represented by line 148, by a thread of execution, referred to as a ‘timer thread’ 100. Timer thread 100 manages a queue, or list, 120 of tasks to be run ordered by ‘next time to run’ (with the nearest time to run being on top of list 120). When the closest task 122 is ready to run, timer thread 100 awakens and, as is represented by line 102, executes task 122. During this action (the running of the task) the remaining tasks 124, 126 waiting on queue 120 are not eligible to run. This is true even if the waiting tasks are currently ready or become ready to run while current task 122 is running. This is due to the fact that the timer thread 100 can only process a single task at a time. Upon completion of task 122, timer thread becomes available to execute, as is represented by line 104, the next task, in this case, task 124, when it is ready to run. A condition, referred to as ‘starvation’, occurs when task 124 becomes ready to run before task 122 completes.
In general, with timer thread N (100) currently running task N (122) and task N+1 (124) becomes ready to run, because task N 122 is not yet available (has not yet released timer thread N 100), task N+1 (124) will starve until a thread N+1 is created, or becomes available, to handle it. (In this example, timer thread 100 functions as thread N and as thread N+1.)